<?php

function get_domain($domain) {
	
	if(empty($domain)) return array();

	$temp = explode("://",$domain);

	if (count($temp) >= 2) {
		$mydomain = $temp[1];
	} else {
		$mydomain = $temp[0];
	}

	$temp2 = explode("/",$mydomain);

	foreach ($temp2 as $path) {

		 $path = trim( $path);

		 if (!empty($path) ) {
			 $actual = trim($path);
			 break;
		 }
	}
	if (strtolower(substr($actual,0,4)) == 'www.') {
		$with_www = $actual;
		$without_www = substr($actual,4);
	} else {
		$with_www = 'www.'.$actual;
		$without_www = $actual;
	}

	return array($with_www, $without_www);
}

?>